<script type="text/javascript">

function onschedulingsubmit()
{
	var startdate = document.getElementById("start_date");
	var enddate = document.getElementById("end_date");
	if (isEmpty(startdate,"Start Date Can't Be Empty"))
	{
		return false;
	}
	if (isEmpty(enddate,"End Date Can't Be Empty"))
	{
		return false;
	}
	var dt1=toDate(startdate.value);
    var dt2=toDate(enddate.value);
    
	if (dt1>dt2)
	{
		alert("Start Date Can't Bigger Than End Date");
		enddate.focus();
		return false;
	}
	document.myform.submit();
	return true;
}
function toDate(mydate)
{
	var dtStr = mydate;
	var dtArr = dtStr.split("-");
	var dt = new Date(dtArr[0], dtArr[1], dtArr[2]);
	return dt;
}
function isEmpty(id,msg)
{
	if (id.value=="")
	{
		alert(msg);
		id.focus();
		return true;
	}
	return false;
}
</script>
<form id="myform" name="myform" action="<?php echo base_url("index.php/scheduling/storescheduling")?>" method="post">
<input id="type" name ="type" type="hidden" value="3"/>
      <fieldset>
      <legend>Auto Scheduling</legend>
      <table class="nostyle">
        <tr>
          <td style="width:120px;">Start Date:</td>
          <td><input type="text" size="40" name=start_date id="start_date"  size="40" class="input-text Wdate"
             readonly="readonly" onFocus="WdatePicker({lang:'en',dateFmt:'yyyy-MM-dd'})" /></td>
        </tr>
        <tr>
          <td style="width:120px;">End Date:</td>
          <td><input type="text" size="40" name="end_date" id="end_date"  size="40" class="input-text Wdate"
             readonly="readonly" onFocus="WdatePicker({lang:'en',dateFmt:'yyyy-MM-dd'})" /></td>
        </tr>
        <tr>
          <td colspan="2" class="t-right"><input type="button" class="input-submit" value="Commit" onclick="onschedulingsubmit();"/></td>
        </tr>
      </table>
      </fieldset>

</form>
